<template>
    
    <!-- 组件的模板 -->
    <div class="page attendance-set">
        <div class="weui-cells weui-cells_radio">
            <label class="weui-cell weui-check__label" for="x11">
                <div class="weui-cell__bd">
                    <p>提交不需要通知</p>
                </div>
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" name="radio1" id="x11" value="0" v-model="noticeType">
                    <span class="weui-icon-checked"></span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x12">
                <div class="weui-cell__bd">
                    <p>仅考勤状态异常时通知</p>
                </div>
                <div class="weui-cell__ft">
                    <input type="radio" name="radio1" class="weui-check" id="x12" value="1" v-model="noticeType">
                    <span class="weui-icon-checked"></span>
                </div>
            </label>            
            <label class="weui-cell weui-check__label" for="x13">
                <div class="weui-cell__bd">
                    <p>提交考勤即通知</p>
                </div>
                <div class="weui-cell__ft">
                    <input type="radio" name="radio1" class="weui-check" id="x13" value="2" v-model="noticeType">
                    <span class="weui-icon-checked"></span>
                </div>
            </label>            
        </div>
    </div>
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import cache from 'gapi/cache.js'
    import commonPage from 'clientApi/commonPage.js'
    import KCApiApp from 'clientApi/KCApiApp.js'
    import * as util from 'js/util.js'
    
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                noticeType:'0'
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                cache.getMemoryCache('noticeType', (data) => {
                    this.noticeType = data.key
                })
            },
            submit(){
                // alert(this.noticeType)
                if(this.noticeType == 0){
                    //埋点
                    let statisticsLog_data = {
                        event_id: '新建考勤规则-提交不需要通知_确定',
                        // event_label: data.event_label,(预留，现在不用传此参数)
                        event_param: {
                            ca_from: 'nopush',
                            project_id: util.getQueryString('project_id'),
                        }
                    }
                    // alert(JSON.stringify(statisticsLog_data))
                    KCApiApp.statisticsLog(statisticsLog_data)
                }else if(this.noticeType == 1){
                    //埋点
                    let statisticsLog_data = {
                        event_id: '新建考勤规则-仅考勤状态异常时通知_确定',
                        // event_label: data.event_label,(预留，现在不用传此参数)
                        event_param: {
                            ca_from: 'pushonlywarning',
                            project_id: util.getQueryString('project_id'),
                        }
                    }
                    // alert(JSON.stringify(statisticsLog_data))
                    KCApiApp.statisticsLog(statisticsLog_data)
                }else if(this.noticeType == 2){
                    //埋点
                    let statisticsLog_data = {
                        event_id: '新建考勤规则-提交考勤即通知_确定',
                        // event_label: data.event_label,(预留，现在不用传此参数)
                        event_param: {
                            ca_from: 'push',
                            project_id: util.getQueryString('project_id'),
                        }
                    }
                    // alert(JSON.stringify(statisticsLog_data))
                    KCApiApp.statisticsLog(statisticsLog_data)
                }

                commonPage.goBack(1,{'key':'noticeType','value':this.noticeType})
            }
        },
        created(){
            this.init();
             /**
             * 设置 添加考勤任务按钮
             * @type {String}
             */
            commonPage.updateTitleBar({
                backAction: '',
                leftDisplay: false,
                leftText: '',
                leftAction: '',
                rightDisplay: true,
                rightText: '确定',
                rightAction: 'doSubmit'
            })

            window.doSubmit = this.submit
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/attendance.css"></style>
